home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2 - Developers' Solutions / Delphi 2 Developers' Solutions.iso / dds / chap09 / howto02 / cciccinf.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-06-11  |  3.1 KB  |  103 lines

  1. unit Cciccinf;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, Grids, Outline, CCWSock;
  8.  
  9. type
  10.   TCCICInfoDlg = class(TForm)
  11.     Panel1: TPanel;
  12.     BitBtn1: TBitBtn;
  13.     BitBtn2: TBitBtn;
  14.     Panel4: TPanel;
  15.     ListBox2: TListBox;
  16.     Panel2: TPanel;
  17.     Edit1: TEdit;
  18.     Panel3: TPanel;
  19.     Edit2: TEdit;
  20.     Panel5: TPanel;
  21.     Edit3: TEdit;
  22.     Panel8: TPanel;
  23.     Edit4: TEdit;
  24.     Panel9: TPanel;
  25.     Edit5: TEdit;
  26.     Panel6: TPanel;
  27.     Outline1: TOutline;
  28.     Label1: TLabel;
  29.     Label2: TLabel;
  30.     Button1: TButton;
  31.     Button2: TButton;
  32.     Button3: TButton;
  33.     Button4: TButton;
  34.     procedure Button1Click(Sender: TObject);
  35.   private
  36.     { Private declarations }
  37.   public
  38.     { Public declarations }
  39.   end;
  40.  
  41. var
  42.   CCICInfoDlg: TCCICInfoDlg;
  43.  
  44. implementation
  45.  
  46. uses CCICCFrm;
  47.  
  48. {$R *.DFM}
  49. procedure TCCICInfoDlg.Button1Click(Sender: TObject);
  50. var TempSocket : TCCSocket; { Used for IP Address info }
  51.     DataBuffer : array[ 0 .. 256 ] of char;
  52. begin
  53.   case Tag of
  54.     1 : begin  { Get IP Address Mode }
  55.           { Create the dummy socket }
  56.           TempSocket := TCCSocket.Create( Self );
  57.           TempSocket.Parent := Self;
  58.           { Use it to get the info }
  59.           with TempSocket do
  60.           begin
  61.             { Move the IP address into the data buffer }
  62.             StrPCopy( DataBuffer , Edit1.Text );
  63.             { Turn it into a real IP address in binary form }
  64.             Socket_IP_Address.Socket_Address.Full_Internet_Address :=
  65.              inet_addr( DataBuffer );
  66.             { If not found then do remote lookup }
  67.             if Socket_IP_Address.Socket_Address.Full_Internet_Address = INADDR_NONE then
  68.             begin
  69.               { Call blocking function on IP name }
  70.               Socket_Host_Entry := gethostbyname( DataBuffer );
  71.               { If still no good then error out and exit }
  72.               if Socket_Host_Entry = nil then
  73.               begin
  74.                 Edit2.Text := 'Could Not Convert Host Name';
  75.                 Edit3.Text := '';
  76.               end
  77.               else
  78.               begin
  79.                 { Otherwise get the address }
  80.                 Socket_IP_Address.Socket_Address :=
  81.                  Socket_Host_Entry^.Host_Address^^;
  82.                 Edit2.Text :=
  83.                  IntToStr( Socket_IP_Address.Socket_Address.Net_Byte ) + '.' +
  84.                  IntToStr( Socket_IP_Address.Socket_Address.Host_Byte ) + '.' +
  85.                  IntToStr( Socket_IP_Address.Socket_Address.Local_Host_Byte ) +
  86.                  '.' + IntToStr(
  87.                  Socket_IP_Address.Socket_Address.Local_Machine_Byte );
  88.                 Edit3.Text :=
  89.                  IntToStr( Socket_IP_Address.Socket_Address.
  90.                             Full_Internet_Address );
  91.               end;
  92.             end;
  93.           end;
  94.           { Free the dummy socket }
  95.           TempSocket.Free;
  96.         end;
  97.   end;
  98. end;
  99.  
  100. { This procedure saves the newly modified list of stuff to its base }
  101. { This method cancels any changes made from entries in current setup & exits}
  102. end.
  103.